﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using smartphone.App_Code;
using System.Data;

namespace smartphone.UserControls
{
    public partial class CommentsBlock : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string contentID = "";
            if (Request.QueryString["ProductId"] != null)
            {
                contentID = Request.QueryString["ProductId"].ToString();
            }
            else if (Request.QueryString["ProductId"] == null && Request.QueryString["NewsId"] != null)
            {
                contentID = Request.QueryString["NewsId"].ToString();
            }

            PopulateControl(Int32.Parse(contentID));
        }

        private void PopulateControl(int productID)
        {
            Comment comm = new Comment();
            DataTable temp = comm.GetComments(productID);
            if (temp.Rows.Count > 0)
            {
                LabelCommentHead.Visible = true;
                RepeaterComment.DataSource = temp;
                RepeaterComment.DataBind();
            }
        }
    }
}